<template>
  <div>
    <h3>孙</h3>
    <h3>爷爷给了我{{sum}}本书</h3>
    <h3>爷爷给了我一辆{{car.c1}}</h3>
    <h3>爷爷给了我一辆{{car.c2}}</h3>
    <button @click="buyBook(2)">给爷爷买2本书</button>
  </div>
</template>

<script setup lang='ts' nmae="GrandSon">
import { ref, reactive, inject } from 'vue'

let {sum,buyBook}:any = inject('aa')
// let {sum,buyBook}:any = inject('aa',{sum:ref(0),buyBook:(val:number)=>{sum.value += 10*val}})
// console.log(buyBook);

let car:any = inject('bbb',{c1:"花朵",c2:"大树"})
// let booksum = inject('aaa',()=>{
//   return 2*10
// },false)
// let booksum = inject('aaa',()=>{
//   return 2*10
// },true)
</script>


<style lang='scss' scoped>

</style>